package IT09;

import java.util.ArrayList;
import java.util.Collections;

/*
模拟斗地主
 */
public class PokerDemo01 {
    public static void main(String[] args) {
        //创建一个牌盒，也就是定义一个集合对象
        ArrayList<String> array = new ArrayList<>();
        //往牌盒里装牌
        /*
        ♦2...
        ♥2...
        ♠2...
        ♣2...
        大小王
        */
        //定义花色数组
        String[] colors = {"♦", "♥", "♠", "♣"};
        //定义点数数组
        String[] numbers = {"2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"};
        for (String color : colors) {
            for (String number : numbers) {
                array.add(color + number);
            }
        }
        array.add("大王");
        array.add("小王");
        //洗牌
        Collections.shuffle(array);
        //发牌,遍历集合，给三个玩家发牌
        ArrayList<String> lqxArray = new ArrayList<>();
        ArrayList<String> lyArray = new ArrayList<>();
        ArrayList<String> fqyArray = new ArrayList<>();
        ArrayList<String> dpArray = new ArrayList<>();
        for (int i = 0; i < array.size(); i++) {
            String poker = array.get(i);
            if (i >= array.size() - 3) {
                dpArray.add(poker);
            } else if (i % 3 == 0) {
                lqxArray.add(poker);
            } else if (i % 3 == 1) {
                lyArray.add(poker);
            } else if (i % 3 == 2) {
                fqyArray.add(poker);
            }
        }
        //看牌，也就是三个玩家分别遍历自己的牌
        lookpoker("林青霞",lqxArray);
        lookpoker("柳岩",lyArray);
        lookpoker("风清扬",fqyArray);
        lookpoker("底牌",dpArray);
    }

    //看牌的方法
    public static void lookpoker(String name, ArrayList<String> array) {
        System.out.println(name + "的牌是：");
        for (String poker : array) {
            System.out.println(poker + "");
        }
        System.out.println();
    }
}
